package com.song.service.Impl;

import com.song.dao.DeptMapper;
import com.song.pojo.Dept;
import com.song.service.DeptService;
import com.song.vo.DeptVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * @author 宋超
 * HP - the login name of the current user.
 * 2020/12/6 - the current system date.
 * 11:40 - the current system time.
 */
@Service
@Transactional
public class DeptServiceImpl implements DeptService {

    @Resource
    private DeptMapper deptMapper;

    public List<Dept> findDeptListByPage(DeptVo deptVo) {
        List<Dept> deptListByPage = deptMapper.findDeptListByPage(deptVo);
        return deptListByPage;
    }

    //添加部门信息
    public int addDept(Dept dept) {
        dept.setCreateDate(new Date());
        return deptMapper.addDept(dept);
    }

    //修改部门信息
    public int updateDept(Dept dept) {
        return deptMapper.updateDept(dept);
    }


    //删除部门信息
    public int deleteById(Integer id) {
        int deptId = deptMapper.deleteById(id);
        return deptId;
    }

    //查询所有部门
    public List<Dept> findDeptList() {
        return deptMapper.findDeptList();
    }
}
